import { Mask } from 'antd-mobile'
import React from 'react'
import styles from './index.module.less'
import coinImg from '@/resource/vision/coin.png'
import closeImg from '@/resource/home/close.png'
import type { ModalPropsType } from './interface'
import { levelPathMap } from '@/const'
import { history, createBrowserHistory } from 'umi'

const TaskFinshModal = (props: ModalPropsType) => {
    const { onClose, levelInfo, visible } = props

    const handleClick = () => {
        history.push(`/level?id=${levelInfo?.scene_id}`)
        // if (levelInfo?.is_last === '1') {
        //     history.push('/home')
        // } else {
        //     // const path = levelPathMap.get(`${levelInfo.nextBarrier.type}`)
        //     // console.log(path)
        //     // const historys = createBrowserHistory({
        //     //     basename: '', //基链接
        //     //     forceRefresh: true, //是否强制刷新
        //     // })
        //     // historys.push(`${path}/${levelInfo.nextBarrier.id}`)
        // }
    }

    return (
        <div className={styles.modal_container} style={{ display: visible ? 'block' : 'none' }}>
            <Mask visible />
            <div className={styles.modal_main}>
                <div className={styles.modal_header}>
                    <div className={styles.title}>任务完成</div>
                    <img className={styles.close_btn} src={closeImg} onClick={onClose} />
                </div>
                <div className={styles.modal_content}>
                    <div>
                        关卡{levelInfo.sort}：{levelInfo.name}，任务已完成，收获一枚金币
                    </div>
                    <img className={styles.coin_img} src={coinImg} />
                    <div className={styles.ok_btn} onClick={handleClick}>
                        OK
                    </div>
                </div>
            </div>
        </div>
    )
}

export default TaskFinshModal
